package cn.ubeta.b2c.bean;

import android.text.TextUtils;
import android.util.Base64;

import java.util.List;

/**
 * Created by denny on 16/9/6.
 */

public class AddressInfo extends ApiResp<List<AddressInfo>> {

    private String title;
    private long addressId;
    /**
     * addressType : 1
     * name : null
     * provinceId : 1
     * cityId : 2800
     * countyId : 2848
     * townId : 0
     * provinceName : null
     * cityName : null
     * countyName : null
     * townName : null
     * addressDetail : 世纪中心
     * postCode : null
     * mobile : MTg1MTAxNjgyMzQ=
     * phone : null
     * email : null
     * longitude : 1000
     * latitude : 1000
     * coord_type : 2
     * pickId : 0
     * pickName : null
     * paymentId : 0
     * addressName : null
     * addressDefault : false
     */

    private int addressType;
    private String name;
    private int provinceId;
    private int cityId;
    private int countyId;
    private int townId;
    private String provinceName;
    private String cityName;
    private String countyName;
    private String townName;
    private String addressDetail;
    private String postCode;
    private String mobile;
    private String phone;
    private String email;
    private int longitude;
    private int latitude;
    private int coord_type;
    private int pickId;
    private String pickName;
    private int paymentId;
    private String addressName;
    private boolean addressDefault;

    public static List<AddressInfo> getTestData() {
        return null;
        /*
        List<AddressInfo> data = new ArrayList<>();
        for (int i = 0; i < 12; ++i) {
            AddressInfo info = new AddressInfo();
            info.title = "地址" + i;
            info.addressId = i;
            data.add(info);
        }
        return data;
        */
    }

    public String getTitle() {
        return title;
    }

    public long getAddressId() {
        return addressId;
    }

    public int getAddressType() {
        return addressType;
    }

    public void setAddressType(int addressType) {
        this.addressType = addressType;
    }

    public String getDisplayName() {
        // 手机号
        String m = mobile;
        if (!TextUtils.isEmpty(m)) {
            m = new String(Base64.decode(m, Base64.DEFAULT));
            m = m.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
        } else {
            m = "";
        }
        return name + " " + m;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getProvinceId() {
        return provinceId;
    }

    public void setProvinceId(int provinceId) {
        this.provinceId = provinceId;
    }

    public int getCityId() {
        return cityId;
    }

    public void setCityId(int cityId) {
        this.cityId = cityId;
    }

    public int getCountyId() {
        return countyId;
    }

    public void setCountyId(int countyId) {
        this.countyId = countyId;
    }

    public int getTownId() {
        return townId;
    }

    public void setTownId(int townId) {
        this.townId = townId;
    }

    public String getProvinceName() {
        return provinceName;
    }

    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public String getCountyName() {
        return countyName;
    }

    public void setCountyName(String countyName) {
        this.countyName = countyName;
    }

    public String getTownName() {
        return townName;
    }

    public void setTownName(String townName) {
        this.townName = townName;
    }

    public String getAddressDetail() {
        return addressDetail;
    }

    public String getDisplayAddressDetail() {
        return String.format("%s %s %s %s", provinceName, cityName, countyName, addressDetail);
    }

    public void setAddressDetail(String addressDetail) {
        this.addressDetail = addressDetail;
    }

    public String getPostCode() {
        return postCode;
    }

    public void setPostCode(String postCode) {
        this.postCode = postCode;
    }

    public String getMobile() {
        return mobile;
    }

    public String getDecodedMobile() {
        if (TextUtils.isEmpty(mobile))
            return "";
        return new String(Base64.decode(mobile, Base64.DEFAULT));
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getLongitude() {
        return longitude;
    }

    public void setLongitude(int longitude) {
        this.longitude = longitude;
    }

    public int getLatitude() {
        return latitude;
    }

    public void setLatitude(int latitude) {
        this.latitude = latitude;
    }

    public int getCoord_type() {
        return coord_type;
    }

    public void setCoord_type(int coord_type) {
        this.coord_type = coord_type;
    }

    public int getPickId() {
        return pickId;
    }

    public void setPickId(int pickId) {
        this.pickId = pickId;
    }

    public String getPickName() {
        return pickName;
    }

    public void setPickName(String pickName) {
        this.pickName = pickName;
    }

    public int getPaymentId() {
        return paymentId;
    }

    public void setPaymentId(int paymentId) {
        this.paymentId = paymentId;
    }

    public String getAddressName() {
        return addressName;
    }

    public void setAddressName(String addressName) {
        this.addressName = addressName;
    }

    public boolean isAddressDefault() {
        return addressDefault;
    }

    public void setAddressDefault(boolean addressDefault) {
        this.addressDefault = addressDefault;
    }

    public void setAddressId(long addressId) {
        this.addressId = addressId;
    }
}
